//
//  ZRCommon.h
//  简书:https://www.jianshu.com/u/043e94ca450f
//
//  Created by 黄涛 on 2018/8/9.
//  Copyright © 2018年 黄涛(ZR:zero). All rights reserved.
//  头文件 + 宏定义

#ifndef ZRCommon_h
#define ZRCommon_h

#import "ZRConst.h"

/** ****************  第三方 ***************/
#import <AFNetworking/AFNetworking.h>
#import <Masonry/Masonry.h>
#import <MJExtension/MJExtension.h>
#import <SDWebImage/UIImageView+WebCache.h>


/** ****************  Category ***************/
#import "UIView+ZRExtension.h"
#import "UIFont+ZRExtension.h"
#import "UIColor+ZRExtension.h"
#import "NSString+ZRExtension.h"

/** ****************  Tool ***************/
#import "ZRNetworkingTool.h"


/** 快速设置颜色 */
#define ZRColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
#define ZRColorAlpha(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

/** 全局灰色背景色 */
#define ZRGlobalBgColor ZRSameRGBColor(242)

/** 主色调 */
#define ZRMainColor ZRColor(138, 198, 51)

/** button主题色 */
#define ZRBtnColor ZRColor(81,150,214)

/** 导航条背景色 */
#define ZRNavBgColor ZRColor(138, 198, 51)

/** 全局分隔线灰色 */
#define ZRGraySepLineColor ZRSameRGBColor(227)

/** 全局灰色字体颜色 */
#define ZRGrayTextColor ZRSameRGBColor(153)

/** 随机色 */
#define ZRRandomColor [UIColor colorWithRed:arc4random_uniform(100)/100.0 green:arc4random_uniform(100)/100.0 blue:arc4random_uniform(100)/100.0 alpha:1]

#define ZRRandomColorAlpha(a) [UIColor colorWithRed:arc4random_uniform(100)/100.0 green:arc4random_uniform(100)/100.0 blue:arc4random_uniform(100)/100.0 alpha:(a)]

/** RGB相等颜色 */
#define ZRSameRGBColor(rgb) [UIColor colorWithRed:(rgb)/255.0 green:(rgb)/255.0 blue:(rgb)/255.0 alpha:1]

#define ZRSameRGBColorAlpha(rgb, a) [UIColor colorWithRed:(rgb)/255.0 green:(rgb)/255.0 blue:(rgb)/255.0 alpha:(a)]


#define KPCOLOR(hex) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16)) / 255.0 green:((float)((hex & 0xFF00) >> 8)) / 255.0 blue:((float)(hex & 0xFF)) / 255.0 alpha:1]

/** 四英寸屏幕缩小 */
#define ZRFourInchScale (([UIScreen mainScreen].bounds.size.width < 330) ? 0.853 : 1)
/** 弱引用self */
#define ZRWeakSelf __weak typeof(self) weakSelf = self;


/** 屏幕bounds */
#define ZRScreenBounds [UIScreen mainScreen].bounds
/** 屏幕宽度 */
#define ZRScreenW [UIScreen mainScreen].bounds.size.width
/** 屏幕高度 */
#define ZRScreenH [UIScreen mainScreen].bounds.size.height

#define ZRHomeCellImageWH (([UIScreen mainScreen].bounds.size.width - 40) / 3)
/** 判断是否为 iPhone X */
#define ZRIsIphoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

/** 状态栏高度 */
#define ZRStatusBarHeight ([UIApplication sharedApplication].statusBarFrame.size.height)

/** 导航栏 + 状态栏高度 */
#define ZRNavBarHeight (self.navigationController.navigationBar.hash ? (self.navigationController.navigationBar.frame.size.height + ZRStatusBarHeight) : ZRIsIphoneX ? (88) : (64))

/** TabBar 高度 */
#define ZRTabBarHeight (self.tabBarController.tabBar.frame.size.height)

/** 安全区域 到 底部距离*/
#define ZRBottomInset ZRIsIphoneX ? (-34) : (0)


#endif /* ZRCommon_h */
